package org.mat.admin.sys.controller;









import org.mat.admin.sys.api.domain.SysOperLog;
import org.mat.admin.sys.controller.page.TableDataInfo;
import org.mat.admin.sys.service.ISysOperLogService;
import org.mat.framework.lang.dto.MatApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 操作日志记录
 * 
 * @author ruoyi
 */
@RestController
@RequestMapping("/operlog")
public class SysOperlogController extends BaseController
{
    @Autowired
    private ISysOperLogService operLogService;


    @GetMapping("/list")
    public TableDataInfo list(SysOperLog operLog)
    {
        startPage();
        List<SysOperLog> list = operLogService.selectOperLogList(operLog);
        return getDataTable(list);
    }


//    @PostMapping("/export")
//    public void export(HttpServletResponse response, SysOperLog operLog)
//    {
//        List<SysOperLog> list = operLogService.selectOperLogList(operLog);
//        ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class);
//        util.exportExcel(response, list, "操作日志");
//    }


    @DeleteMapping("/{operIds}")
    public MatApiResponse remove(@PathVariable Long[] operIds)
    {
        return toAjax(operLogService.deleteOperLogByIds(operIds));
    }


    @DeleteMapping("/clean")
    public MatApiResponse clean()
    {
        operLogService.cleanOperLog();
        return MatApiResponse.success(null);
    }

    @PostMapping
    public MatApiResponse add(@RequestBody SysOperLog operLog)
    {
        return toAjax(operLogService.insertOperlog(operLog));
    }
}
